# This analysis was conducted using R Studio Version 1.1.419 for Mac and R version 3.5.2 for Mac
install.packages("pacman")
pacman::p_load(foreign, ggplot2, plm, reshape2, countrycode, sandwich, lmtest, MASS, 
               rworldmap, RColorBrewer, states, mice, VIM, stargazer, margins, clusterSEs, lme4, optimx,
               coefplot, topicmodels, tm, tidytext, dplyr, wordcloud, class, interplot, DataCombine, sjPlot,
               msm, reporttools, dplyr, igraph, NetMix, dnr, statnet, network, sna, stm) # load relevant packages

setwd("ENTER DIRECTORY") # set working directory (change to your directory)

#### Create Datasets ####
wbcollab <- read.csv("wb_collab.csv") # load hand-coded data on collaboration among development IOs
wbcollab$coopagg <- wbcollab$cofin + wbcollab$infoshare # code aggregate cooperation to only include inforshare and cofin
wbcollab$coopbin <- 0 # create a binary for cooperation
wbcollab$coopbin[wbcollab$coopagg > 0] <- 1 # code the binary
wbcollab2 <- read.csv("wb_collab_clean.csv") # load data with hand-coded covariates
wbcollab2$memdiff <- abs(wbcollab2$io1nummem - wbcollab2$io2nummem) # calculate differences in memberships
wbcollab2$dyid <- paste(wbcollab2$io1short, wbcollab2$io2short) # assign dyad ID
lagdv1 <- slide(wbcollab2, Var = "infoshare", GroupVar = "dyid",
                          slideBy = 1, NewVar = 'infosharelag') # create lag variable for infoshare
lagdv2 <- slide(wbcollab2, Var = "cofin", GroupVar = "dyid",
                slideBy = 1, NewVar = 'cofinlag') # create lag variable for cofin
wbcollab2 <- cbind(wbcollab2, lagdv1$infosharelag) # merge in first lag
wbcollab2 <- cbind(wbcollab2, lagdv2$cofinlag) # merge in second lag
colnames(wbcollab2)[27] <- "infosharelag" # rename columns
colnames(wbcollab2)[28] <- "cofinlag"
un <- read.csv("unidealpt.csv") # load dyadic UN voting data downloaded from Bailey et al. (2017) in November 2018 V21 https://doi.org/10.7910/DVN/LEJUQZ
atop <- read.csv("ally.csv") # load ATOP alliance data from Leeds et al. (2002)  downloaded in November 2018
dist <- read.csv("capdist.csv") # load data on distance between country capitals from https://egallic.fr/en/closest-distance-between-countries/
peace <- read.csv("peacedata.csv") # load peace data from Goertz et al. (2016) downloaded in January 2020
wbcollab2$wbbin <- ifelse(wbcollab2$io1short == "IBRD", 1, 0) # create binary variable for World Bank involvement
wbcollab2$io1topsh <- as.character(wbcollab2$io1topsh) # change data format to character
wbcollab2$io2topsh <- as.character(wbcollab2$io2topsh)
wbcollab2$hqctry1 <- as.character(wbcollab2$hqctry1)
wbcollab2$hqctry2 <- as.character(wbcollab2$hqctry2)
wbcollab2$io1topshc <- countrycode(wbcollab2$io1topsh, origin = "country.name", destination = "cown") # create country code variables for both shareholder and HQ countries 
wbcollab2$io2topshc <- countrycode(wbcollab2$io2topsh, origin = "country.name", destination = "cown")
wbcollab2$hqctry1c <- countrycode(wbcollab2$hqctry1, origin = "country.name", destination = "cown")
wbcollab2$hqctry2c <- countrycode(wbcollab2$hqctry2, origin = "country.name", destination = "cown")
wbcollab2$idealptsh <- NA # create empty variables for UN distance, alliance ties, and rivalry-peace between leading stakeholders
wbcollab2$idealpthq <- NA # variables are then generated in the loops below
wbcollab2$allysh <- NA
wbcollab2$allyhq <- NA
wbcollab2$hqdist <- NA
wbcollab2$shpeace <- NA
for (i in 1:5758) {
  un1 <- un$idealpt[un$ccode == wbcollab2$io1topshc[i] & un$year == wbcollab2$year[i]]
  un2 <- un$idealpt[un$ccode == wbcollab2$io2topshc[i] & un$year == wbcollab2$year[i]]
  un3 <- un$idealpt[un$ccode == wbcollab2$hqctry1c[i] & un$year == wbcollab2$year[i]]
  un4 <- un$idealpt[un$ccode == wbcollab2$hqctry2c[i] & un$year == wbcollab2$year[i]]
  wbcollab2$idealptsh[i] <- ifelse(is.numeric(abs(un1 - un2)), abs(un1 - un2),NA)
  wbcollab2$idealpthq[i] <- ifelse(is.numeric(abs(un3 - un4)), abs(un3 - un4),NA)
  wbcollab2$idealptsh[i] <- ifelse(wbcollab2$io1topshc == wbcollab2$io2topshc, 0, wbcollab2$idealptsh[i])
  wbcollab2$idealpthq[i] <- ifelse(wbcollab2$hqctry1c == wbcollab2$hqctry2c, 0, wbcollab2$idealpthq[i])
} # loop to complete UN voting variables

for (i in 1:5758) {
  a1 <- atop$defense[(atop$ccode1 == wbcollab2$io1topshc[i] & atop$ccode2 == wbcollab2$io2topshc[i] &
                       atop$year == wbcollab2$year[i]) | (atop$ccode2 == wbcollab2$io1topshc[i] & 
                                                         atop$ccode1 == wbcollab2$io2topshc[i] &
                                                         atop$year == wbcollab2$year[i])]
  a2 <- atop$defense[(atop$ccode1 == wbcollab2$hqctry1c[i] & atop$ccode2 == wbcollab2$hqctry2c[i] &
                        atop$year == wbcollab2$year[i]) | (atop$ccode2 == wbcollab2$hqctry1c[i] & 
                                                             atop$ccode1 == wbcollab2$hqctry2c[i] &
                                                             atop$year == wbcollab2$year[i])]
  wbcollab2$allysh[i] <- ifelse(is.numeric(a1), a1,NA)
  wbcollab2$allyhq[i] <- ifelse(is.numeric(a2), a2,NA)
  wbcollab2$allysh[i] <- ifelse(wbcollab2$io1topshc == wbcollab2$io2topshc, 1, wbcollab2$allysh[i])
  wbcollab2$allyhq[i] <- ifelse(wbcollab2$hqctry1c == wbcollab2$hqctry2c, 1, wbcollab2$allyhq[i])
} # loop to complete alliance ties variables

wbcollab2$allysh[is.na(wbcollab2$allysh)] <- 0 # mark NA as 0 for alliance ties since data only includes 1s
wbcollab2$allyhq[is.na(wbcollab2$allyhq)] <- 0

for (i in 1:5758) {
  d1 <- dist$dist[(dist$ccode1 == wbcollab2$hqctry1c[i] & dist$ccode2 == wbcollab2$hqctry2c[i]) | 
                     (dist$ccode2 == wbcollab2$hqctry1c[i] & dist$ccode1 == wbcollab2$hqctry2c[i])]
  wbcollab2$hqdist[i] <- ifelse(is.numeric(d1), d1, NA)
  wbcollab2$hqdist[i] <- ifelse(wbcollab2$hqctry1c[i] == wbcollab2$hqctry2c[i], 0, wbcollab2$hqdist[i])
} # loop to complete geographic distance variables

for (i in 1:5758) {
  p1 <- peace$peace[(peace$ccode1 == wbcollab2$io1topshc[i] & peace$ccode2 == wbcollab2$io2topshc[i] &
                      peace$year == wbcollab2$year[i]) | 
  (peace$ccode2 == wbcollab2$io1topshc[i] & peace$ccode1 == wbcollab2$io2topshc[i] & peace$year == wbcollab2$year[i])]
  wbcollab2$shpeace[i] <- ifelse(is.numeric(p1), p1,NA)
  wbcollab2$shpeace[i] <- ifelse(wbcollab2$io1topshc[i] == wbcollab2$io2topshc[i], 1, wbcollab2$shpeace[i])
} # loop to complete rivalary-peace variables

wbcollab2lag <- wbcollab2[-c(6:10, 22:23)] # lag main independent variables
wbcollab2lag$year <- wbcollab2lag$year + 1
temp <- wbcollab2[c(2,4:7, 22:23)]
wbcollab2lag <- merge(wbcollab2lag, temp, by = c("io1short", "io2short", "year")) # rename variables

devmem <- read.csv("development_membership.csv") # load hand-coded data on membership in development IOs
devmem$IBRD <- 1 # code all countries as members of World Bank
wbcollab2$memoverlap <- NA # create empty variable for membership overlap to be filled in with the loop below
for (i in 1:5758) {
  io1 <- wbcollab2$io1short[i]
  io2 <- wbcollab2$io2short[i]
  c1 <- devmem$ccode[devmem[, io1] == 1]
  c2 <- devmem$ccode[devmem[, io2] == 1]
  c3 <- c(c1, c2)
  c3 <- unique(c3)
  wbcollab2$memoverlap[i] <- length(intersect(c1, c2)) / length(c3)
} # complete the membership overlap variable

elite <- read.csv("elitesurv_clean.csv") # load elite survey data collected in February 2020 via LinkedIn -- see paper Appendix for more
elite$disb[elite$disb == 10] <- 10000 # recode disbursement amounts in millions
elite$disb[elite$disb == 20] <- 20000
elite$topsh <- ifelse(elite$org == "World Bank", "United States",
                      ifelse(elite$org == "Asian Development Bank", "Japan",
                             ifelse(elite$org == "African Development Bank", "Nigeria",
                                    ifelse(elite$org == "Inter-American Development Bank", "United States",
                                           ifelse(elite$org == "International Fund for Agricultural Development", "United States",
                                                  ifelse(elite$org == "Central American Bank for Economic Integration", "Costa Rica",
                                                         ifelse(elite$org == "Islamic Development Bank", "Saudi Arabia",
                                                                ifelse(elite$org == "Eurasian Development Bank", "Russia", NA)))))))) # code leading shareholders for survey data
elite$tophq <- ifelse(elite$org == "World Bank", "United States",
                      ifelse(elite$org == "Asian Development Bank", "Philippines",
                             ifelse(elite$org == "African Development Bank", "Ivory Coast",
                                    ifelse(elite$org == "Inter-American Development Bank", "United States",
                                           ifelse(elite$org == "International Fund for Agricultural Development", "Italy",
                                                  ifelse(elite$org == "Central American Bank for Economic Integration", "Honduras",
                                                         ifelse(elite$org == "Islamic Development Bank", "Saudi Arabia",
                                                                ifelse(elite$org == "Eurasian Development Bank", "Kazakhstan", NA)))))))) # code HQ locations for survey data

elite$orgdisb <- ifelse(elite$org == "World Bank", 49235,
                      ifelse(elite$org == "Asian Development Bank", 14190,
                             ifelse(elite$org == "African Development Bank", 5987,
                                    ifelse(elite$org == "Inter-American Development Bank", 9900,
                                           ifelse(elite$org == "International Fund for Agricultural Development", 910,
                                                  ifelse(elite$org == "Central American Bank for Economic Integration", 1860,
                                                         ifelse(elite$org == "Islamic Development Bank", 538,
                                                                ifelse(elite$org == "Eurasian Development Bank", 243, NA)))))))) # code org disbursements using 2018 figures for survey data

elite$orgnummem <- ifelse(elite$org == "World Bank", 189,
                        ifelse(elite$org == "Asian Development Bank", 60,
                               ifelse(elite$org == "African Development Bank", 80,
                                      ifelse(elite$org == "Inter-American Development Bank", 48,
                                             ifelse(elite$org == "International Fund for Agricultural Development", 160,
                                                    ifelse(elite$org == "Central American Bank for Economic Integration", 8,
                                                           ifelse(elite$org == "Islamic Development Bank", 53,
                                                                  ifelse(elite$org == "Eurasian Development Bank", 6, NA)))))))) # code membership using 2018 figures for survey data

elite$topshc <- countrycode(elite$topsh, origin = "country.name", destination = "cown") # create country code variables for leading shareholders
elite$tophqc <- countrycode(elite$tophq, origin = "country.name", destination = "cown")
elite$sharec <- countrycode(elite$share, origin = "country.name", destination = "cown")
elite$hqc <- countrycode(elite$hq, origin = "country.name", destination = "cown")
elite$natc <- countrycode(elite$nation, origin = "country.name", destination = "cown")

elite$memdiff <- abs(elite$nummem - elite$orgnummem) # create difference in number of members variable
elite$resdiff <- abs(elite$disb - elite$orgdisb) # create difference in disbursements variable

elite$idealptsh <- NA # create empty variables for geopolitical ties again, and then fill in with loops
elite$idealpthq <- NA
elite$allysh <- NA
elite$allyhq <- NA
elite$hqdist <- NA
elite$shpeace <- NA
for (i in 1:668) {
  un1 <- un$idealpt[un$ccode == elite$topshc[i] & un$year == 2018]
  un2 <- un$idealpt[un$ccode == elite$sharec[i] & un$year == 2018]
  un3 <- un$idealpt[un$ccode == elite$tophqc[i] & un$year == 2018]
  un4 <- un$idealpt[un$ccode == elite$hqc[i] & un$year == 2018]
  un5 <- un$idealpt[un$ccode == elite$natc[i] & un$year == 2018]
  elite$idealptsh[i] <- ifelse(is.numeric(abs(un1 - un2)), abs(un1 - un2),NA)
  elite$idealpthq[i] <- ifelse(is.numeric(abs(un3 - un4)), abs(un3 - un4),NA)
  elite$idealptsh[i] <- ifelse(elite$topshc == elite$sharec, 0, elite$idealptsh[i])
  elite$idealpthq[i] <- ifelse(elite$tophqc == elite$hqc, 0, elite$idealpthq[i])
  elite$idealptnat[i] <- ifelse(is.numeric(abs(un2 - un5)), abs(un2 - un5),NA)
}

for (i in 1:668) {
  a1 <- atop$defense[(atop$ccode1 == elite$topshc[i] & atop$ccode2 == elite$sharec[i] &
                        atop$year == 2012) | (atop$ccode2 == elite$topshc[i] & 
                                                             atop$ccode1 == elite$sharec[i] &
                                                             atop$year == 2012)]
  a2 <- atop$defense[(atop$ccode1 == elite$hqc[i] & atop$ccode2 == elite$tophqc[i] &
                        atop$year == 2012) | (atop$ccode2 == elite$hqc[i] & 
                                                             atop$ccode1 == elite$tophqc[i] &
                                                             atop$year == 2012)]
  elite$allysh[i] <- ifelse(is.numeric(a1), a1,NA)
  elite$allyhq[i] <- ifelse(is.numeric(a2), a2,NA)
  elite$allysh[i] <- ifelse(elite$topshc == elite$sharec, 1, elite$allysh[i])
  elite$allyhq[i] <- ifelse(elite$hqc == elite$tophqc, 1, elite$allyhq[i])
}

elite$allysh[is.na(elite$allysh)] <- 0
elite$allyhq[is.na(elite$allyhq)] <- 0

for (i in 1:668) {
  d1 <- dist$dist[(dist$ccode1 == elite$hqc[i] & dist$ccode2 == elite$tophqc[i]) | 
                    (dist$ccode2 == elite$hqc[i] & dist$ccode1 == elite$tophqc[i])]
  elite$hqdist[i] <- ifelse(is.numeric(d1), d1, NA)
  elite$hqdist[i] <- ifelse(elite$hqc[i] == elite$tophqc[i], 0, elite$hqdist[i])
}

for (i in 1:668) {
  peace2 <- peace[peace$year == 2015,]
  p1 <- peace2$peace[(peace2$ccode1 == elite$topshc[i] & peace2$ccode2 == elite$sharec[i]) | 
                      (peace2$ccode2 == elite$topshc[i] & peace2$ccode1 == elite$sharec[i])]
  elite$shpeace[i] <- ifelse(is.numeric(p1), p1, NA)
  elite$shpeace[i] <- ifelse(elite$topshc[i] == elite$sharec[i], 1, elite$shpeace[i])
}

elite$west <- 0 # create variable for western vs. non IOs
elite$west[!(elite$org == "Other" | elite$org == "Islamic Development Bank" | elite$org == "Eurasian Development Bank")] <- 1

elite2 <- elite[elite$iteration == 1,] # create dataset with just first iteration from experiment for each respondent
elite$china <- ifelse(elite$hq == "China",1,0) # create binaries for leading shareholders and HQ locations in profiles
elite$russia <- ifelse(elite$hq == "Russia",1,0)
elite$us <- ifelse(elite$hq == "USA",1,0)
elite2$china <- ifelse(elite2$hq == "China",1,0)
elite2$russia <- ifelse(elite2$hq == "Russia",1,0)
elite2$us <- ifelse(elite2$hq == "USA",1,0)

emp <- read.csv("devstaff.csv") # load data on number of employees at each development bank in experimental sample
# data was hand-coded from IO websites and LinkedIn
elite3 <- left_join(elite, emp, by = "org", all.x=T) # merge data sets
elite3$numstaff <- elite3$numstaff / sum(emp$numstaff) # calculate share of all dev staff employed by each IO

lend <- read.csv("aiddata.csv") # load data on lending activities of MDBs downloaded from AidData in Jan 2020 with custom query
lend2 <- read.csv("aiddata1.csv") # AidData is split across two sheets, so download second sheet
lend <- rbind(lend, lend2) # append data together
lendagg <- aggregate(list(lend$Amount..Constant.USD2014.), by = list(lend$Receiver.Country.ISO, lend$Funding.Organization,
                                                                     lend$Year),
                     FUN = sum) # aggregate data by country, IO, and year
lendagg <- lendagg[!lendagg$Group.2 == "",] # eliminate empty rows
lendagg <- lendagg[!lendagg$Group.1 == "",]
colnames(lendagg) <- c("ccode", "io", "year", "lendamt") # change col names
lendagg$ccode <- countrycode(lendagg$ccode, origin = "iso2c", destination = "iso3c") # generate country codes
lendagg <- lendagg[!is.na(lendagg$ccode),] # delete NA rows
lendagg$io[lendagg$io == "WORLD BANK" | lendagg$io == "World Bank"] <- "IBRD" # recode abbreviations for each IO to match my data
lendagg$io[lendagg$io == "ASDB Group"] <- "ADB"
lendagg$io[lendagg$io == "Inter-American Development Bank (IADB)"] <- "IADB"
lendagg$io[lendagg$io == "OPEC Fund for International Development (OFID)"] <- "OFID"
lendagg$io[lendagg$io == "Arab Fund for Economic & Social Development (AFESD)"] <- "AFESD"
lendagg$io[lendagg$io == "Andean Development Corporation (CAF)"] <- "CAF"
lendagg$io[lendagg$io == "European Bank for Reconstruction & Development (EBRD)"] <- "EBRD"
lendagg$io[lendagg$io == "AFDB Group"] <- "AfDB"
lendagg$io[lendagg$io == "Arab Bank for Economic Development in Africa (BADEA)"] <- "BADEA"
lendagg$io[lendagg$io == "Islamic Development Bank (ISDB)"] <- "IsDB"
lendagg$io[lendagg$io == "International Fund for Agricultural Development (IFAD)"] <- "IFAD"
lendagg$io[lendagg$io == "Nordic Development Fund (NDF)"] <- "NDF"
lendagg$io[lendagg$io == "North American Development Bank (NADB)"] <- "NADB"
lendagg$io[lendagg$io == "Caribbean Development Bank (CDB)"] <- "CDB"

for (i in 1:14229) {
  tempyr <- lendagg$year[i]
  tempio <- lendagg$io[i]
  lendagg$share[i] <- lendagg$lendamt[i] / sum(lendagg$lendamt[lendagg$year == tempyr & 
                                                                 lendagg$io == tempio]) 
} # code share of lending for portfolio similarity measure

lendc <- unique(lendagg$ccode) # eliminate duplicates
infl <- read.csv("inflation.csv") # load data on inflation (CPI) downloaded from World Development Indicators in Jan 2020
colnames(infl) <- c("year", "yearcode", "ctry", "ccode", "inflation", "CPI") # change col names
infl[infl == ".."] <- NA # replace ".." with NA
infl$year <- as.numeric(infl$year) # change data format
infl$CPI <- as.numeric(infl$CPI)
wbcollab2$risk <- NA # create empty variables for risk and portfolio similarity, as described in paper
wbcollab2$portsim <- NA

for (i in 1:5758) {
  tempyr <- wbcollab2$year[i]
  tempio1 <- wbcollab2$io1short[i]
  tempio2 <- wbcollab2$io2short[i]
  portsim <- 0
  risk <- 0
  for (j in 1:198) {
    tempc <- lendc[j]
    portsim <- portsim + abs(sum(lendagg$share[lendagg$io == tempio1 & lendagg$year == tempyr & lendagg$ccode == tempc], 
                                 -lendagg$share[lendagg$io == tempio2 & lendagg$year == tempyr & lendagg$ccode == tempc],
                                 na.rm=T))
    prod1 <- prod(lendagg$share[lendagg$io == tempio1 & lendagg$year == tempyr & lendagg$ccode == tempc],
                  infl$CPI[infl$year == tempyr & infl$ccode == tempc], 
                  lendagg$share[lendagg$io == tempio2 & lendagg$year == tempyr & lendagg$ccode == tempc],
                  infl$CPI[infl$year == tempyr & infl$ccode == tempc], na.rm=T)
    risk <- risk + ifelse(prod1 == 1, 0, prod1)
  }
  wbcollab2$portsim[i] <- portsim
  wbcollab2$risk[i] <- risk
} # complete the portsim and risk variables

wbcollab2$risk <- scale(wbcollab2$risk) # standardize the risk measure
wbcollab2$portsim <- wbcollab2$portsim*-1 # adjust the portsim measure to be 0-1
iofund <- unique(lendagg$io) # eliminate duplicates
wbcollab2$portsim[!(wbcollab2$io1short %in% iofund) | !(wbcollab2$io2short %in% iofund)] <- NA # recode NAs
wbcollab2$risk[!(wbcollab2$io1short %in% iofund) | !(wbcollab2$io2short %in% iofund)] <- NA

lendagg2 <- aggregate(lendagg$lendamt, by = list(lendagg$io, lendagg$year), FUN = sum) # aggregate by IO-year
colnames(lendagg2) <- c("io1short", "year", "lendamt") # rename cols
wbcollab2 <- merge(wbcollab2, lendagg2, by = c("io1short", "year"), all.x = T) # merge back in
colnames(wbcollab2)[43] <- "aidbudget1" # rename cols
colnames(lendagg2) <- c("io2short", "year", "lendamt") 
wbcollab2 <- merge(wbcollab2, lendagg2, by = c("io2short", "year"), all.x = T) # merge back in
colnames(wbcollab2)[44] <- "aidbudget2" # rename cols
wbcollab2$aidbudgetdiff <- abs(wbcollab2$aidbudget1 - wbcollab2$aidbudget2) # take absolute value for aid budget difference
hqco <- read.csv("hqco.csv") # load hand-coded data on IO headquarters co-locations
wbcollab2 <- merge(unique(wbcollab2), unique(hqco), by = c("io1short", "io2short")) # merge into data
wbcollab2$allysh[wbcollab2$io1topsh == wbcollab2$io2topsh] <- 1 # code same leading shareholder as 1 on alliance

#### Descriptive Plot  ####
wbagg <- aggregate(list(wbcollab$cofin, wbcollab$infoshare), by = list(wbcollab$year), FUN = sum) # aggregate collab by type and year
colnames(wbagg) <- c("year", "cofin", "infoshare") # change col names
wbmelt <- melt(wbagg, id.var='year') # reformat data
wbmelt$variable <- as.character(wbmelt$variable) # reformat data
wbmelt$variable[wbmelt$variable == "cofin"] <- "Co-financing" # change name of var type
wbmelt$variable[wbmelt$variable == "infoshare"] <- "Information Sharing"
wbmelt %>%
  ggplot(aes(x = year, y = value, fill = variable)) +
  theme_bw() + 
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(x = "Year", y = "Cooperation Amount", fill = "Cooperation Type") +
  theme(axis.title.x = element_text(size = 18), axis.title.y = element_text(size = 18),
        legend.title = element_text(size = 18),legend.text = element_text(size = 16))  # Figure A1

#### Descriptive Stats (Observational data) ####
covs_desc <- c("Information sharing", "Co-financing", "UN voting (ideal pt. dist)", "Rivalry-Peace", 
               "Alliance", "Difference in IO size", "HQ distance", "Member overlap") # assign variable names
desc <- wbcollab2 # re-assign main data to temp object
desc <- desc[,-c(1:5,8:24, 26:33,35,37,41:46)] # subset to relevant variables
desc <- desc[c(1,2,4,7,5,3,6,8)]
stargazer(desc, omit.summary.stat = c("p25", "p75"), digits = 2, style = "ajps",
          covariate.labels = covs_desc) # Table A4

#### Observational Analysis ####
##->## Each IV alone (main results)
# Steps are described in comments for main results and then repeated for each robustness check
rob1 <- glm.nb(infoshare ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + year, 
             data = wbcollab2) # info share DV with UN voting key IV and controls
(serob1 <- coeftest(rob1, vcov = vcovHC(rob1, type = "HC1", cluster = wbcollab2$dyid))) # calculate SEs

rob1b <- glm.nb(infoshare ~ shpeace + memdiff + log1p(hqdist) + memoverlap + year, 
               data = wbcollab2) # info share DV with rivalry-peace key IV and controls
(serob1b <- coeftest(rob1b, vcov = vcovHC(rob1b, type = "HC1", cluster = wbcollab2$dyid))) # calculate SEs

rob1c <- glm.nb(infoshare ~ allysh + memdiff + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2)  # info share DV with alliance key IV and controls
(serob1c <- coeftest(rob1c, vcov = vcovHC(rob1c, type = "HC1", cluster = wbcollab2$dyid))) # calculate SEs

covs2 <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance", "Difference in IO size", 
          "HQ distance", "Member overlap", "Year")
stargazer(rob1, rob1b, rob1c, se = list(serob1[,2], serob1b[,2], serob1c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covs2, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in paper as Table 2

rob1d <- glm.nb(cofin ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + year, 
               data = wbcollab2) # cofin DV with UN voting key IV and controls
(serob1d <- coeftest(rob1d, vcov = vcovHC(rob1d, type = "HC1", cluster = wbcollab2$dyid))) # calculate SEs

rob1e <- glm.nb(cofin ~ shpeace + memdiff + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2) # cofin DV with rivalry-peace key IV and controls
(serob1e <- coeftest(rob1e, vcov = vcovHC(rob1e, type = "HC1", cluster = wbcollab2$dyid))) # calculate SEs

rob1f <- glm.nb(cofin ~ allysh + memdiff + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2) # cofin DV with alliance key IV and controls
(serob1f <- coeftest(rob1f, vcov = vcovHC(rob1f, type = "HC1", cluster = wbcollab2$dyid))) # calculate SEs

stargazer(rob1d, rob1e, rob1f, se = list(serob1d[,2], serob1e[,2], serob1f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covs2, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in paper as Table 3

##->## With port sim and risk variables added for robustness
rob1 <- glm.nb(infoshare ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + portsim + risk + year, 
               data = wbcollab2)
(serob1 <- coeftest(rob1, vcov = vcovHC(rob1, type = "HC0", cluster = wbcollab2$dyid)))

rob1b <- glm.nb(infoshare ~ shpeace + memdiff + log1p(hqdist) + memoverlap + portsim + risk + year, 
                data = wbcollab2)
(serob1b <- coeftest(rob1b, vcov = vcovHC(rob1b, type = "HC0", cluster = wbcollab2$dyid)))

rob1c <- glm.nb(infoshare ~ allysh + memdiff + log1p(hqdist) + memoverlap + portsim + risk + year, 
                data = wbcollab2)
(serob1c <- coeftest(rob1c, vcov = vcovHC(rob1c, type = "HC0", cluster = wbcollab2$dyid)))

covs2a <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance", "Difference in IO size", 
           "HQ distance", "Member overlap", "Portfolio similarity", "Risk", "Year")
stargazer(rob1, rob1b, rob1c, se = list(serob1[,2], serob1b[,2], serob1c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covs2a, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A15

rob1d <- glm.nb(cofin ~ idealptsh + memdiff + log1p(hqdist) + portsim + risk + cofinlag + year, 
                data = wbcollab2)
(serob1d <- coeftest(rob1d, vcov = vcovHC(rob1d, type = "HC0", cluster = wbcollab2$dyid)))

rob1e <- glm.nb(cofin ~ shpeace + memdiff + log1p(hqdist) + portsim + risk + cofinlag + year, 
                data = wbcollab2)
(serob1e <- coeftest(rob1e, vcov = vcovHC(rob1e, type = "HC0", cluster = wbcollab2$dyid)))

rob1f <- glm.nb(cofin ~ allysh + memdiff + log1p(hqdist) + portsim + risk + cofinlag + year, 
                data = wbcollab2)
(serob1f <- coeftest(rob1f, vcov = vcovHC(rob1f, type = "HC0", cluster = wbcollab2$dyid)))

stargazer(rob1d, rob1e, rob1f, se = list(serob1d[,2], serob1e[,2], serob1f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covs2a, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A16

##->## With aid budgets instead of IO size for robustness

rob1 <- glm.nb(infoshare ~ idealptsh + log1p(aidbudgetdiff) + log1p(hqdist) + memoverlap + year, 
               data = wbcollab2)
(serob1 <- coeftest(rob1, vcov = vcovHC(rob1, type = "HC0", cluster = wbcollab2$dyid)))

rob1b <- glm.nb(infoshare ~ shpeace + log1p(aidbudgetdiff) + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2, control=glm.control(maxit=20))
(serob1b <- coeftest(rob1b, vcov = vcovHC(rob1b, type = "HC0", cluster = wbcollab2$dyid)))

rob1c <- glm.nb(infoshare ~ allysh + log1p(aidbudgetdiff) + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2)
(serob1c <- coeftest(rob1c, vcov = vcovHC(rob1c, type = "HC0", cluster = wbcollab2$dyid)))

covs2a <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance", "Difference in aid budgets", 
            "HQ distance", "Member overlap", "Year")
stargazer(rob1, rob1b, rob1c, se = list(serob1[,2], serob1b[,2], serob1c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covs2a, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A7

rob1d <- glm.nb(cofin ~ idealptsh + log1p(aidbudgetdiff) + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2)
(serob1d <- coeftest(rob1d, vcov = vcovHC(rob1d, type = "HC0", cluster = wbcollab2$dyid)))

rob1e <- glm.nb(cofin ~ shpeace + log1p(aidbudgetdiff) + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2)
(serob1e <- coeftest(rob1e, vcov = vcovHC(rob1e, type = "HC0", cluster = wbcollab2$dyid)))

rob1f <- glm.nb(cofin ~ allysh + log1p(aidbudgetdiff) + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2)
(serob1f <- coeftest(rob1f, vcov = vcovHC(rob1f, type = "HC0", cluster = wbcollab2$dyid)))

stargazer(rob1d, rob1e, rob1f, se = list(serob1d[,2], serob1e[,2], serob1f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covs2a, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A8

##->## HQ co-location variable added robustness check

rob1 <- glm.nb(infoshare ~ idealptsh + memdiff + hqco + memoverlap + year, 
               data = wbcollab2)
(serob1 <- coeftest(rob1, vcov = vcovHC(rob1, type = "HC0", cluster = wbcollab2$dyid)))

rob1b <- glm.nb(infoshare ~ shpeace + memdiff + hqco + memoverlap + year, 
                data = wbcollab2)
(serob1b <- coeftest(rob1b, vcov = vcovHC(rob1b, type = "HC0", cluster = wbcollab2$dyid)))

rob1c <- glm.nb(infoshare ~ allysh + memdiff + hqco + memoverlap + year, 
                data = wbcollab2)
(serob1c <- coeftest(rob1c, vcov = vcovHC(rob1c, type = "HC0", cluster = wbcollab2$dyid)))

covs2 <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance", "Difference in IO size", 
           "HQ co-location", "Member overlap", "Year")
stargazer(rob1, rob1b, rob1c, se = list(serob1[,2], serob1b[,2], serob1c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covs2, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A9

rob1d <- glm.nb(cofin ~ idealptsh + memdiff + hqco + memoverlap + year, 
                data = wbcollab2)
(serob1d <- coeftest(rob1d, vcov = vcovHC(rob1d, type = "HC0", cluster = wbcollab2$dyid)))

rob1e <- glm.nb(cofin ~ shpeace + memdiff + hqco + memoverlap + year, 
                data = wbcollab2)
(serob1e <- coeftest(rob1e, vcov = vcovHC(rob1e, type = "HC0", cluster = wbcollab2$dyid)))

rob1f <- glm.nb(cofin ~ allysh + memdiff + hqco + memoverlap + year, 
                data = wbcollab2)
(serob1f <- coeftest(rob1f, vcov = vcovHC(rob1f, type = "HC0", cluster = wbcollab2$dyid)))

stargazer(rob1d, rob1e, rob1f, se = list(serob1d[,2], serob1e[,2], serob1f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covs2, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A10

##->## Year FEs added robustness check
rob2 <- glm.nb(infoshare ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + factor(year), 
               data = wbcollab2)
(serob2 <- coeftest(rob2, vcov = vcovHC(rob2, type = "HC0", cluster = wbcollab2$dyid)))

rob2b <- glm.nb(infoshare ~ shpeace + memdiff + log1p(hqdist) + memoverlap + factor(year), 
                data = wbcollab2)
(serob2b <- coeftest(rob2b, vcov = vcovHC(rob2b, type = "HC0", cluster = wbcollab2$dyid)))

rob2c <- glm.nb(infoshare ~ allysh + memdiff + log1p(hqdist) + memoverlap + factor(year), 
                data = wbcollab2, control=glm.control(maxit=20))
(serob2c <- coeftest(rob2c, vcov = vcovHC(rob2c, type = "HC0", cluster = wbcollab2$dyid)))


covs3 <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance", "Difference in IO size", 
           "HQ distance", "Member overlap")
stargazer(rob2, rob2b, rob2c, se = list(serob2[,2], serob2b[,2], serob2c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covs3,
          style = "ajps", omit = c("year", "Constant"),
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A11

rob2d <- glm.nb(cofin ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + factor(year), 
                data = wbcollab2)
(serob2d <- coeftest(rob2d, vcov = vcovHC(rob2d, type = "HC0", cluster = wbcollab2$dyid)))

rob2e <- glm.nb(cofin ~ shpeace + memdiff + log1p(hqdist) + memoverlap + factor(year), 
                data = wbcollab2)
(serob2e <- coeftest(rob2e, vcov = vcovHC(rob2e, type = "HC0", cluster = wbcollab2$dyid)))

rob2f <- glm.nb(cofin ~ allysh + memdiff + log1p(hqdist) + memoverlap + factor(year), 
                data = wbcollab2, control=glm.control(maxit=20))
(serob2f <- coeftest(rob2f, vcov = vcovHC(rob2f, type = "HC0", cluster = wbcollab2$dyid)))

stargazer(rob2d, rob2e, rob2f, se = list(serob2d[,2], serob2e[,2], serob2f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covs3,
          style = "ajps", omit = c("year", "Constant"),
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A12

##->## Bivariate robustness check

rob4 <- glm.nb(infoshare ~ idealptsh + year, 
               data = wbcollab2)
(serob4 <- coeftest(rob4, vcov = vcovHC(rob4, type = "HC0", cluster = wbcollab2$dyid)))

rob4b <- glm.nb(infoshare ~ shpeace + year, 
                data = wbcollab2)
(serob4b <- coeftest(rob4b, vcov = vcovHC(rob4b, type = "HC0", cluster = wbcollab2$dyid)))

rob4c <- glm.nb(infoshare ~ allysh + year, 
                data = wbcollab2, control=glm.control(maxit=20))
(serob4c <- coeftest(rob4c, vcov = vcovHC(rob4c, type = "HC0", cluster = wbcollab2$dyid)))


covs5 <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance", "Year")
stargazer(rob4, rob4b, rob4c, se = list(serob4[,2], serob4b[,2], serob4c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covs5,
          style = "ajps", omit = c("Constant"),
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A13

rob4d <- glm.nb(cofin ~ idealptsh + year, 
                data = wbcollab2)
(serob4d <- coeftest(rob4d, vcov = vcovHC(rob4d, type = "HC0", cluster = wbcollab2$dyid)))

rob4e <- glm.nb(cofin ~ shpeace + year,  
                data = wbcollab2)
(serob4e <- coeftest(rob4e, vcov = vcovHC(rob4e, type = "HC0", cluster = wbcollab2$dyid)))

rob4f <- glm.nb(cofin ~ allysh + year,  
                data = wbcollab2, control=glm.control(maxit=20))
(serob4f <- coeftest(rob4f, vcov = vcovHC(rob4f, type = "HC0", cluster = wbcollab2$dyid)))

stargazer(rob4d, rob4e, rob4f, se = list(serob4d[,2], serob4e[,2], serob4f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covs5,
          style = "ajps", omit = c("Constant"),
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A14

##->## Exclude same powerful stakeholder in both IO dyads robustness check
wbcollab2a <- wbcollab2[wbcollab2$io1topsh != wbcollab2$io2topsh,] # exclude dyads with same leading stakeholder
rob1 <- glm.nb(infoshare ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + year, 
               data = wbcollab2a)
(serob1 <- coeftest(rob1, vcov = vcovHC(rob1, type = "HC0", cluster = wbcollab2a$dyid)))

rob1b <- glm.nb(infoshare ~ shpeace + memdiff + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2a)
(serob1b <- coeftest(rob1b, vcov = vcovHC(rob1b, type = "HC0", cluster = wbcollab2a$dyid)))

rob1c <- glm.nb(infoshare ~ allysh + memdiff + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2a)
(serob1c <- coeftest(rob1c, vcov = vcovHC(rob1c, type = "HC0", cluster = wbcollab2a$dyid)))

covs2 <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance", "Difference in IO size", 
           "HQ distance", "Member overlap", "Year")
stargazer(rob1, rob1b, rob1c, se = list(serob1[,2], serob1b[,2], serob1c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covs2, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A5

rob1d <- glm.nb(cofin ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2a)
(serob1d <- coeftest(rob1d, vcov = vcovHC(rob1d, type = "HC0", cluster = wbcollab2a$dyid)))

rob1e <- glm.nb(cofin ~ shpeace + memdiff + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2a)
(serob1e <- coeftest(rob1e, vcov = vcovHC(rob1e, type = "HC0", cluster = wbcollab2a$dyid)))

rob1f <- glm.nb(cofin ~ allysh + memdiff + log1p(hqdist) + memoverlap + year, 
                data = wbcollab2a)
(serob1f <- coeftest(rob1f, vcov = vcovHC(rob1f, type = "HC0", cluster = wbcollab2a$dyid)))

stargazer(rob1d, rob1e, rob1f, se = list(serob1d[,2], serob1e[,2], serob1f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covs2, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta")) # Appears in appendix as Table A6

##->## Iteratively drop each IO
unit_string <- unique(c(unique(wbcollab2$io1short), unique(wbcollab2$io2short))) # look for unique IO codes
it_drop_info <- data.frame(matrix(nrow = 28, ncol = 7)) # prep data to iteratively drop each
colnames(it_drop_info) <- c("dv", "idealptsh", "shpeace", "allysh", "seideal", "sepeace", "seally") # change col names
it_drop_info$dv <- rep(c("Information sharing"), 28) # repeat for each DV
it_drop_cofin <- data.frame(matrix(nrow = 28, ncol = 7))
colnames(it_drop_cofin) <- c("dv", "idealptsh", "shpeace", "allysh", "seideal", "sepeace", "seally")
it_drop_cofin$dv <- rep(c("Co-financing"), 28) 
it_drop_info$drop <- NA # create empty variable for effect size, which is resolved with loop below
it_drop_cofin$drop <- NA
for (i in 1:28) {
  data = wbcollab2[wbcollab2$io1short != unit_string[i] & wbcollab2$io2short != unit_string[i],]
  
  reg_object_1 <- glm.nb(infoshare ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + year, 
                        data = data)
  (sereg1 <- coeftest(reg_object_1, vcov = vcovHC(reg_object_1, type = "HC1", cluster = data$dyid)))
  reg_object_2 <- glm.nb(infoshare ~ shpeace + memdiff + log1p(hqdist) + memoverlap + year, 
                         data = data)
  (sereg2 <- coeftest(reg_object_2, vcov = vcovHC(reg_object_2, type = "HC1", cluster = data$dyid)))
  reg_object_3 <- glm.nb(infoshare ~ allysh + memdiff + log1p(hqdist) + memoverlap + year, 
                         data = data)
  (sereg3 <- coeftest(reg_object_3, vcov = vcovHC(reg_object_3, type = "HC1", cluster = data$dyid)))
  reg_object_4 <- glm.nb(cofin ~ idealptsh + memdiff + log1p(hqdist) + memoverlap + year, 
                         data = data)
  (sereg4 <- coeftest(reg_object_4, vcov = vcovHC(reg_object_4, type = "HC1", cluster = data$dyid)))
  reg_object_5 <- glm.nb(cofin ~ shpeace + memdiff + log1p(hqdist) + memoverlap + year, 
                         data = data)
  (sereg5 <- coeftest(reg_object_5, vcov = vcovHC(reg_object_5, type = "HC1", cluster = data$dyid)))
  reg_object_6 <- glm.nb(cofin ~ allysh + memdiff + log1p(hqdist) + memoverlap + year, 
                         data = data)
  (sereg6 <- coeftest(reg_object_6, vcov = vcovHC(reg_object_6, type = "HC1", cluster = data$dyid)))
  
  coeftemp <- sereg1[,1]
  setemp <- sereg1[,2]
  it_drop_info$idealptsh[i] <- unname(coeftemp[c(2)])
  it_drop_info$seideal[i] <- unname(setemp[c(2)])
  coeftemp <- sereg2[,1]
  setemp <- sereg2[,2]
  it_drop_info$shpeace[i] <- unname(coeftemp[c(2)])
  it_drop_info$sepeace[i] <- unname(setemp[c(2)])
  coeftemp <- sereg3[,1]
  setemp <- sereg3[,2]
  it_drop_info$allysh[i] <- unname(coeftemp[c(2)])
  it_drop_info$seally[i] <- unname(setemp[c(2)])
  coeftemp <- sereg4[,1]
  setemp <- sereg4[,2]
  it_drop_cofin$idealptsh[i] <- unname(coeftemp[c(2)])
  it_drop_cofin$seideal[i] <- unname(setemp[c(2)])
  coeftemp <- sereg5[,1]
  setemp <- sereg5[,2]
  it_drop_cofin$shpeace[i] <- unname(coeftemp[c(2)])
  it_drop_cofin$sepeace[i] <- unname(setemp[c(2)])
  coeftemp <- sereg6[,1]
  setemp <- sereg6[,2]
  it_drop_cofin$allysh[i] <- unname(coeftemp[c(2)])
  it_drop_cofin$seally[i] <- unname(setemp[c(2)])
  
  it_drop_cofin$drop[i] <- unit_string[i]
  it_drop_info$drop[i] <- unit_string[i]
} # loop re-runs each core model with each IO iteratively dropped
it_drop_info$lowideal <- it_drop_info$idealptsh - (1.960*it_drop_info$seideal) # calculate confidence intervals for each key IV with each DV to plot effects with each dropped
it_drop_info$highideal <- it_drop_info$idealptsh + (1.960*it_drop_info$seideal)
it_drop_info$lowpeace <- it_drop_info$shpeace - (1.960*it_drop_info$sepeace)
it_drop_info$highpeace <- it_drop_info$shpeace + (1.960*it_drop_info$sepeace)
it_drop_info$lowally <- it_drop_info$allysh - (1.960*it_drop_info$seally)
it_drop_info$highally <- it_drop_info$allysh + (1.960*it_drop_info$seally)
it_drop_cofin$lowideal <- it_drop_cofin$idealptsh - (1.960*it_drop_cofin$seideal)
it_drop_cofin$highideal <- it_drop_cofin$idealptsh + (1.960*it_drop_cofin$seideal)
it_drop_cofin$lowpeace <- it_drop_cofin$shpeace - (1.960*it_drop_cofin$sepeace)
it_drop_cofin$highpeace <- it_drop_cofin$shpeace + (1.960*it_drop_cofin$sepeace)
it_drop_cofin$lowally <- it_drop_cofin$allysh - (1.960*it_drop_cofin$seally)
it_drop_cofin$highally <- it_drop_cofin$allysh + (1.960*it_drop_cofin$seally)

resModelinfo <- data.frame(param = rep(c("UN voting (ideal pt. dist)", "Rivalry-peace", "Alliance"), each = 28), 
                        low2.5 = c(it_drop_info$lowideal, it_drop_info$lowpeace, it_drop_info$lowally),
                        est = c(it_drop_info$idealptsh, it_drop_info$shpeace, it_drop_info$allysh),
                        up2.5 = c(it_drop_info$highideal, it_drop_info$highpeace, it_drop_info$highally),
                        Dropped = rep(it_drop_info$drop, 3)) # create data frame amenable to plotting the main effects and confidence intervals for infoshare DV
limits <- aes(ymax  = up2.5, ymin = low2.5)  # set limits for plot

plotinfo <- ggplot(resModelinfo, aes(x=param, y=est, color = Dropped)) + 
  geom_pointrange(limits, position=position_dodge(width=0.2)) + 
  geom_hline(yintercept=0, color="red") + 
  theme_bw() + 
  theme(text = element_text(size=18), axis.title.y = element_blank()) +
  ylab(NULL) + 
  coord_flip() +
  ggtitle("Information Sharing") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_x_discrete(limits = rev(levels(as.factor(resModelinfo$param)))) # plot treatment effects with each IO dropped

resModelcofin <- data.frame(param = rep(c("UN voting (ideal pt. dist)", "Rivalry-peace", "Alliance"), each = 28), 
                           low2.5 = c(it_drop_cofin$lowideal, it_drop_cofin$lowpeace, it_drop_cofin$lowally),
                           est = c(it_drop_cofin$idealptsh, it_drop_cofin$shpeace, it_drop_cofin$allysh),
                           up2.5 = c(it_drop_cofin$highideal, it_drop_cofin$highpeace, it_drop_cofin$highally),
                           Dropped = rep(it_drop_cofin$drop, 3)) # repeat same steps for cofinancing DV as above
limits <- aes(ymax  = up2.5, ymin = low2.5) 

plotcofin <- ggplot(resModelcofin, aes(x=param, y=est, color = Dropped)) + 
  geom_pointrange(limits, position=position_dodge(width=0.2)) + 
  geom_hline(yintercept=0, color="red") + 
  theme_bw() + 
  theme(text = element_text(size=18), axis.title.y = element_blank()) +
  ylab(NULL) + 
  coord_flip() +
  ggtitle("Co-financing") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_x_discrete(limits = rev(levels(as.factor(resModelcofin$param))))

plotinfo # show plots, which appear in the appendix as Tables A2-A3
plotcofin

#### Coefficient plots ####
varnames <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance") # variable names to appear in plots
coef1 <- serob1[,1] # for each key geopolitical independent variable and the infoshare DV, extract effect sizes and standard errors
coef1a <- serob1b[,1]
coef1b <- serob1c[,1]
coef1e <- exp(serob1[,1])
coef1ae <- exp(serob1b[,1])
coef1be <- exp(serob1c[,1])
coef1 <- c(unname(coef1[c(2)]), unname(coef1a[c(2)]), unname(coef1b[c(2)]))
coef1e <- c(unname(coef1e[c(2)])-1, unname(coef1ae[c(2)])-1, unname(coef1be[c(2)])-1)
se1 <- serob1[,2]
se1a <- serob1b[,2]
se1b <- serob1c[,2]
se1 <- c(unname(se1[c(2)]), unname(se1a[c(2)]), unname(se1b[c(2)]))
low1 <- exp(coef1 - (1.645*se1))
low1[1] <- low1[1]-1
low1[2] <- low1[2]-1
low1[3] <- low1[3]-1
high1 <- exp(coef1 + (1.645*se1))
high1[1] <- high1[1]-1
high1[2] <- high1[2]-1
high1[3] <- high1[3]-1

coef2 <- serob1d[,1] # for each key geopolitical independent variable and the cofin DV, extract effect sizes and standard errors
coef2a <- serob1e[,1]
coef2b <- serob1f[,1]
coef2e <- exp(serob1d[,1])
coef2ae <- exp(serob1e[,1])
coef2be <- exp(serob1f[,1])
coef2 <- c(unname(coef2[c(2)]), unname(coef2a[c(2)]), unname(coef2b[c(2)]))
coef2e <- c(unname(coef2e[c(2)])-1, unname(coef2ae[c(2)])-1, unname(coef2be[c(2)])-1)
se2 <- serob1d[,2]
se2a <- serob1e[,2]
se2b <- serob1f[,2]
se2 <- c(unname(se2[c(2)]), unname(se2a[c(2)]), unname(se2b[c(2)]))
low2 <- exp(coef2 - (1.645*se2))
high2 <- exp(coef2 + (1.645*se2))
low2[1] <- low2[1]-1
low2[2] <- low2[2]-1
low2[3] <- low2[3]-1
high2[1] <- high2[1]-1
high2[2] <- high2[2]-1
high2[3] <- high2[3]-1

resModel1 <- data.frame(param = varnames, low2.5 = low1, est = coef1e, up2.5 = high1) # set parameters to plot effect sizes
resModel2 <- data.frame(param = varnames, low2.5 = low2, est = coef2e, up2.5 = high2)

limits <- aes(ymax  = up2.5, ymin = low2.5) # set limits for plot

plot1 <- ggplot(resModel1, aes(x=param, y=est)) + 
  geom_pointrange(limits, color = "darkblue", size = 1) + 
  geom_hline(yintercept=0, color="red") + 
  theme_bw() + 
  theme(text = element_text(size=22), axis.text=element_text(size=20), axis.title.y = element_blank()) +
  ylab(NULL) + 
  coord_flip() +
  ggtitle("Information Sharing") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_x_discrete(limits = rev(levels(as.factor(resModel1$param)))) # plot of effect sizes with infoshare DV

plot2 <- ggplot(resModel2, aes(x=param, y=est)) + 
  geom_pointrange(limits, color="darkblue", size = 1) + 
  geom_hline(yintercept=0, color="red") + 
  theme_bw() + 
  theme(text = element_text(size=22), axis.text=element_text(size=20), axis.title.y = element_blank()) +
  ylab(NULL) + 
  coord_flip() +
  ggtitle("Co-financing") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_x_discrete(limits = rev(levels(as.factor(resModel1$param))), labels = element_blank()) +
  scale_y_continuous(breaks =c(-0.25, 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0),
                     labels=c(-0.25, 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0)) # plot of effect sizes with cofin DV

plot1 # appears in paper at Figure 1a
plot2 # appears in paper at Figure 1b

#### Descriptive Stats (Experimental data) ####
covs_desc <- c("Information sharing", "Co-financing", "UN voting (ideal pt. dist)", "Rivalry-Peace", 
               "Alliance", "Difference in memberships", "Difference in disbursements", 
               "HQ distance", "Tenure", "Male", "Age") # create list of covariate labels
desc <- elite # re-assign main exp data
desc <- desc[,-c(1:4,6,9,12:28,32,34,37)] # drop unnecessary variables
desc <- desc[c(5,4,8,11,9,6,7,10,1,2,3)]
stargazer(desc, omit.summary.stat = c("p25", "p75"), digits = 2, style = "ajps",
          covariate.labels = covs_desc) # appears in appendix as Table A19

## Calculate number of respondents in each box
elite$hq <- as.character(elite$hq) # change data format
elite$nummem <- as.numeric(elite$nummem)
elite$id <- as.character(elite$id)
count(elite[elite$hq == "China" & elite$nummem == 5 & elite$disb == 500,]) # for each treatment condition, count number of observations in each box
count(elite[elite$hq == "China" & elite$nummem == 50 & elite$disb == 500,]) # I then manually inputted this into a table, which appears in the appendix
count(elite[elite$hq == "China" & elite$nummem == 100 & elite$disb == 500,]) # as Table A18
count(elite[elite$hq == "China" & elite$nummem == 5 & elite$disb == 10000,])
count(elite[elite$hq == "China" & elite$nummem == 50 & elite$disb == 10000,])
count(elite[elite$hq == "China" & elite$nummem == 100 & elite$disb == 10000,])
count(elite[elite$hq == "China" & elite$nummem == 5 & elite$disb == 20000,])
count(elite[elite$hq == "China" & elite$nummem == 50 & elite$disb == 20000,])
count(elite[elite$hq == "China" & elite$nummem == 100 & elite$disb == 20000,])

count(elite[elite$hq == "Russia" & elite$nummem == 5 & elite$disb == 500,])
count(elite[elite$hq == "Russia" & elite$nummem == 50 & elite$disb == 500,])
count(elite[elite$hq == "Russia" & elite$nummem == 100 & elite$disb == 500,])
count(elite[elite$hq == "Russia" & elite$nummem == 5 & elite$disb == 10000,])
count(elite[elite$hq == "Russia" & elite$nummem == 50 & elite$disb == 10000,])
count(elite[elite$hq == "Russia" & elite$nummem == 100 & elite$disb == 10000,])
count(elite[elite$hq == "Russia" & elite$nummem == 5 & elite$disb == 20000,])
count(elite[elite$hq == "Russia" & elite$nummem == 50 & elite$disb == 20000,])
count(elite[elite$hq == "Russia" & elite$nummem == 100 & elite$disb == 20000,])

count(elite[elite$hq == "USA" & elite$nummem == 5 & elite$disb == 500,])
count(elite[elite$hq == "USA" & elite$nummem == 50 & elite$disb == 500,])
count(elite[elite$hq == "USA" & elite$nummem == 100 & elite$disb == 500,])
count(elite[elite$hq == "USA" & elite$nummem == 5 & elite$disb == 10000,])
count(elite[elite$hq == "USA" & elite$nummem == 50 & elite$disb == 10000,])
count(elite[elite$hq == "USA" & elite$nummem == 100 & elite$disb == 10000,])
count(elite[elite$hq == "USA" & elite$nummem == 5 & elite$disb == 20000,])
count(elite[elite$hq == "USA" & elite$nummem == 50 & elite$disb == 20000,])
count(elite[elite$hq == "USA" & elite$nummem == 100 & elite$disb == 20000,])
#### Experimental Analysis ####
##->## Each IV alone (main results)
covsexp <- c("UN voting (ideal pt. dist)", "Rivalry-Peace", "Alliance",
             "Difference in disbursements", "Number of members", "HQ distance", 
             "Male", "Tenure", "Age", "Iteration") # create list of covariates for results tables
# again, these steps are repeated for all robustness checks, but described here for the main results
exp1 <- lm(infoshare ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$org), 
               data = elite) # run model with infoshare DV and UN voting key independent variable
(seexp1 <- coeftest(exp1, vcov = vcovHC(exp1, type = "HC0", cluster = elite$org))) # compute SEs

exp1b <- lm(infoshare ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$org), 
                data = elite) # run model with infoshare DV and rivalry-peace key independent variable
(seexp1b <- coeftest(exp1b, vcov = vcovHC(exp1b, type = "HC0", cluster = elite$org))) # compute SEs

exp1c <- lm(infoshare ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$org), 
                data = elite) # run model with infoshare DV and alliance key independent variable
(seexp1c <- coeftest(exp1c, vcov = vcovHC(exp1c, type = "HC0", cluster = elite$org))) # compute SEs

stargazer(exp1, exp1b, exp1c, se = list(seexp1[,2], seexp1b[,2], seexp1c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covsexp, omit = c("Constant", "org"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in the paper as Table 4

exp1d <- lm(cofin ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$org), 
                data = elite) # run model with cofin DV and UN voting key independent variable
(seexp1d <- coeftest(exp1d, vcov = vcovHC(exp1d, type = "HC0", cluster = elite$id))) # compute SEs

exp1e <- lm(cofin ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$org), 
                data = elite) # run model with cofin DV and rivalry-peace key independent variable
(seexp1e <- coeftest(exp1e, vcov = vcovHC(exp1e, type = "HC0", cluster = elite$id))) # compute SEs

exp1f <- lm(cofin ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$org), 
                data = elite) # run model with cofin DV and alliance key independent variable
(seexp1f <- coeftest(exp1f, vcov = vcovHC(exp1f, type = "HC0", cluster = elite$id))) # compute SEs

stargazer(exp1d, exp1e, exp1f, se = list(seexp1d[,2], seexp1e[,2], seexp1f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covsexp, omit = c("Constant", "org"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in the paper as Table 5

## Only those who completed the survey robustness check
elitesub <- elite[elite$progress > 98,] # restrict to those who completed the survey
exp2 <- lm(infoshare ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub$org), 
           data = elitesub)
(seexp2 <- coeftest(exp2, vcov = vcovHC(exp2, type = "HC0", cluster = elitesub$org)))

exp2b <- lm(infoshare ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub$org), 
            data = elitesub)
(seexp2b <- coeftest(exp2b, vcov = vcovHC(exp2b, type = "HC0", cluster = elitesub$org)))

exp2c <- lm(infoshare ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub$org), 
            data = elitesub)
(seexp2c <- coeftest(exp2c, vcov = vcovHC(exp2c, type = "HC0", cluster = elitesub$org)))

stargazer(exp2, exp2b, exp2c, se = list(seexp2[,2], seexp2b[,2], seexp2c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covsexp, omit = c("Constant", "org"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A22

exp2d <- lm(cofin ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub$org), 
            data = elitesub)
(seexp2d <- coeftest(exp2d, vcov = vcovHC(exp2d, type = "HC0", cluster = elitesub$org)))

exp2e <- lm(cofin ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub$org), 
            data = elitesub)
(seexp2e <- coeftest(exp2e, vcov = vcovHC(exp2e, type = "HC0", cluster = elitesub$org)))

exp2f <- lm(cofin ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub$org), 
            data = elitesub)
(seexp2f <- coeftest(exp2f, vcov = vcovHC(exp2f, type = "HC0", cluster = elitesub$org)))

stargazer(exp2d, exp2e, exp2f, se = list(seexp2d[,2], seexp2e[,2], seexp2f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covsexp, omit = c("Constant", "org"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq"))  # appears in appendix as Table A23

##->## Only important staff robustness check
elite$title <- as.character(elite$title) # change data format
elitesub2 <- elite[!grepl("intern", elite$title),] # remove interns
elitesub2 <- elitesub2[!grepl("Intern", elitesub2$title),] # remove interns
elitesub2 <- elitesub2[!grepl("Grievance", elitesub2$title),] # remove grievance counselor
elitesub2 <- elitesub2[!grepl("HR", elitesub2$title),] # remove HR folks
elitesub2 <- elitesub2[!grepl("Hr", elitesub2$title),] 
elitesub2 <- elitesub2[!grepl("Receptionist", elitesub2$title),] # remove receptionists
elitesub2 <- elitesub2[!grepl("Diversity", elitesub2$title),] # remove diversity specialists
elitesub2 <- elitesub2[!grepl("Security", elitesub2$title),] # remove security
elitesub2 <- elitesub2[!grepl("University", elitesub2$title),] # remove university students
elitesub2 <- elitesub2[!grepl("Research Assistant", elitesub2$title),] # remove RAs
exp3 <- lm(infoshare ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub2$org), 
           data = elitesub2)
(seexp3 <- coeftest(exp3, vcov = vcovHC(exp3, type = "HC0", cluster = elitesub2$org)))

exp3b <- lm(infoshare ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub2$org), 
            data = elitesub2)
(seexp3b <- coeftest(exp3b, vcov = vcovHC(exp3b, type = "HC0", cluster = elitesub2$org)))

exp3c <- lm(infoshare ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub2$org),  
            data = elitesub2)
(seexp3c <- coeftest(exp3c, vcov = vcovHC(exp3c, type = "HC0", cluster = elitesub2$org)))

stargazer(exp3, exp3b, exp3c, se = list(seexp3[,2], seexp3b[,2], seexp3c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covsexp, omit = c("Constant","org"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A24

exp3d <- lm(cofin ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub2$org),  
            data = elitesub2)
(seexp3d <- coeftest(exp3d, vcov = vcovHC(exp3d, type = "HC0", cluster = elitesub2$org)))

exp3e <- lm(cofin ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub2$org),  
            data = elitesub2)
(seexp3e <- coeftest(exp3e, vcov = vcovHC(exp3e, type = "HC0", cluster = elitesub2$org)))

exp3f <- lm(cofin ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elitesub2$org),  
            data = elitesub2)
(seexp3f <- coeftest(exp3f, vcov = vcovHC(exp3f, type = "HC0", cluster = elitesub2$org)))

stargazer(exp3d, exp3e, exp3f, se = list(seexp3d[,2], seexp3e[,2], seexp3f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covsexp, omit = c("Constant","org"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A25

##->## Respondent fixed-effects robustness check

exp4 <- lm(infoshare ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$id), 
           data = elite)
(seexp4 <- coeftest(exp4, vcov = vcovHC(exp4, type = "HC0", cluster = elite$id)))

exp4b <- lm(infoshare ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$id), 
            data = elite)
(seexp4b <- coeftest(exp4b, vcov = vcovHC(exp4b, type = "HC0", cluster = elite$id)))

exp4c <- lm(infoshare ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$id), 
            data = elite)
(seexp4c <- coeftest(exp4c, vcov = vcovHC(exp4c, type = "HC0", cluster = elite$id)))

stargazer(exp4, exp4b, exp4c, se = list(seexp4[,2], seexp4b[,2], seexp4c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covsexp, omit = c("Constant"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A28, though I manually deleted effects for respondent IDs

exp4d <- lm(cofin ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$id), 
            data = elite)
(seexp4d <- coeftest(exp4d, vcov = vcovHC(exp4d, type = "HC0", cluster = elite$id)))

exp4e <- lm(cofin ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$id), 
            data = elite)
(seexp4e <- coeftest(exp4e, vcov = vcovHC(exp4e, type = "HC0", cluster = elite$id)))

exp4f <- lm(cofin ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + factor(elite$id), 
            data = elite)
(seexp4f <- coeftest(exp4f, vcov = vcovHC(exp4f, type = "HC0", cluster = elite$id)))

stargazer(exp4d, exp4e, exp4f, se = list(seexp4d[,2], seexp4e[,2], seexp4f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covsexp, omit = c("Constant"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A29, though I manually deleted effects for respondent IDs

##->## Weighted by number of employees

exp5 <- lm(infoshare ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration, 
           data = elite3, weights = numstaff)
(seexp5 <- coeftest(exp5, vcov = vcovHC(exp5, type = "HC0", cluster = elite3$id)))

exp5b <- lm(infoshare ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration, 
            data = elite3, weights = numstaff)
(seexp5b <- coeftest(exp5b, vcov = vcovHC(exp5b, type = "HC0", cluster = elite3$id)))

exp5c <- lm(infoshare ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration, 
            data = elite3, weights = numstaff)
(seexp5c <- coeftest(exp5c, vcov = vcovHC(exp5c, type = "HC0", cluster = elite3$id)))

stargazer(exp5, exp5b, exp5c, se = list(seexp5[,2], seexp5b[,2], seexp5c[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covsexp, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A26

exp5d <- lm(cofin ~ idealptsh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration, 
            data = elite3, weights = numstaff)
(seexp5d <- coeftest(exp5d, vcov = vcovHC(exp5d, type = "HC0", cluster = elite3$id)))

exp5e <- lm(cofin ~ shpeace + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration, 
            data = elite3, weights = numstaff)
(seexp5e <- coeftest(exp5e, vcov = vcovHC(exp5e, type = "HC0", cluster = elite3$id)))

exp5f <- lm(cofin ~ allysh + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration, 
            data = elite3, weights = numstaff)
(seexp5f <- coeftest(exp5f, vcov = vcovHC(exp5f, type = "HC0", cluster = elite3$id)))

stargazer(exp5d, exp5e, exp5f, se = list(seexp5d[,2], seexp5e[,2], seexp5f[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covsexp, omit = "Constant",
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A27

##->## US, Russia, and China effects on whole sample robustness check
covsexp2 <- c("U.S.", "China", "Russia",
             "Difference in disbursements", "Number of members", "HQ distance", 
             "Male", "Tenure", "Age", "Iteration")
exp6 <- lm(infoshare ~ us + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + 
             factor(elite$org), data = elite)
(seexp6 <- coeftest(exp6, vcov = vcovHC(exp6, type = "HC0", cluster = elite$org)))

exp6a <- lm(infoshare ~ china + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + 
             factor(elite$org), data = elite)
(seexp6a <- coeftest(exp6a, vcov = vcovHC(exp6a, type = "HC0", cluster = elite$org)))

exp6b <- lm(infoshare ~ russia + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + 
             factor(elite$org), data = elite)
(seexp6b <- coeftest(exp6b, vcov = vcovHC(exp6b, type = "HC0", cluster = elite$org)))

stargazer(exp6, exp6a, exp6b, se = list(seexp6[,2], seexp6a[,2], seexp6b[,2]),
          dep.var.labels = c("Information sharing"),
          covariate.labels = covsexp2, omit = c("Constant", "org"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A20

exp6c <- lm(cofin ~ us + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + 
              factor(elite$org), data = elite)
(seexp6c <- coeftest(exp6c, vcov = vcovHC(exp6c, type = "HC0", cluster = elite$org)))

exp6d <- lm(cofin ~ china + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + 
              factor(elite$org), data = elite)
(seexp6d <- coeftest(exp6d, vcov = vcovHC(exp6d, type = "HC0", cluster = elite$org)))

exp6e <- lm(cofin ~ russia + log1p(resdiff) + nummem + log1p(hqdist) + male + tenure + age + iteration + 
              factor(elite$org), data = elite)
(seexp6e <- coeftest(exp6e, vcov = vcovHC(exp6e, type = "HC0", cluster = elite$org)))

stargazer(exp6c, exp6d, exp6e, se = list(seexp6c[,2], seexp6d[,2], seexp6e[,2]),
          dep.var.labels = c("Co-financing"),
          covariate.labels = covsexp2, omit = c("Constant", "org"),
          style = "ajps",
          omit.stat = c("ll", "aic", "theta", "ser", "F", "rsq", "adj.rsq")) # appears in appendix as Table A21
